/**
 * Created by sun on 2016/8/4.
 */
define(function (require) {
    var app = require('/../js/app');
    require('ui-table');
    app.useModule("ui.table");
    var toastr =require('toastr');
    var datepicker = require('datepicker');
    app.controller('suggestCtrl', ['$scope','$http','$filter',function ($scope, $http,$filter) {
        datepicker($scope);
        $scope.ctrlScope=$scope;
        $scope.ctrlScope.item={};
        //$scope.ctrlScope.first={};
        //$scope.ctrlScope.first1={};
        //$scope.ctrlScope.repay={};

        $scope.orderParams = {
            url: "/admin/userSuggestion/list",
            ajax:{item:'1'}
        };

        $scope.getHours= function () {
            var hours=[];
            for(var i=0;i<24;i++){
                if(i<10){
                    i="0"+i
                }
                hours.push(i)
            }
            return hours;
        };
        $scope.getMins= function () {
            var mins=[];
            for(var i=0;i<60;i++){
                if(i<10){
                    i="0"+i
                }
                mins.push(i)
            }
            return mins;
        };

        //项目统计
        $scope.countItem=function(param){
            $http({
                method: 'POST',
                url:"/admin/item/getCount",
                data:param
            }).success(function (data){
                $scope.ctrlScope.count=data;
            }).error(function(data){

            });
        };
        $scope.countItem();

        //搜索
        $scope.search = function() {
            $scope.ctrlScope.itemsearch.item=1;
            $scope.ctrlScope.itemsearch.beginDate=$scope.ctrlScope.itemsearch.beginDateX;
            $scope.ctrlScope.itemsearch.endDate=$scope.ctrlScope.itemsearch.endDateX;
            $scope.ctrlScope.itemsearch.beginDate=$filter('date')($scope.ctrlScope.itemsearch.beginDate,'yyyy-MM-dd');
            $scope.ctrlScope.itemsearch.endDate=$filter('date')($scope.ctrlScope.itemsearch.endDate,'yyyy-MM-dd');
            $scope.orderParams.ajaxParam=$scope.ctrlScope.itemsearch;
            $scope.orderParams.reload();
        };

        //搜索重置
        $scope.reset=function(){
            $scope.ctrlScope.itemsearch = {};
            $scope.orderParams.ajaxParam={item:1};
            $scope.reload();
            $scope.countItem();
        };


    }])
});